package org.contextsensitivetodo.todoview.model;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class TodoItemsSQLiteOpenHelper extends SQLiteOpenHelper {

	public static final int DB_VERSION = 1;
	private static final String DB_NAME = "todos_db.swlite";
	
	public static final String TODO_TABLE = "todos";
	
	public static final String TODO_ID = "id";
	public static final String TODO_NAME = "name";
	public static final String TODO_COMPLETE = "complete";
	
	
	public TodoItemsSQLiteOpenHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		createTable(db);
	}

	private void createTable(SQLiteDatabase db) {
		db.execSQL("create table " + TODO_TABLE + "(" + 
				TODO_ID + " integer primary key autoincrement not null," +
				TODO_NAME + " text, " +
				TODO_COMPLETE + " text" +
				");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}

}
